package tasker;

import org.mt4j.components.visibleComponents.widgets.buttons.MTImageButton;  
import org.mt4j.input.gestureAction.DefaultDragAction;  
import org.mt4j.input.gestureAction.DefaultScaleAction;  
import org.mt4j.input.inputProcessors.componentProcessors.dragProcessor.DragProcessor;  
import org.mt4j.input.inputProcessors.componentProcessors.scaleProcessor.ScaleProcessor;  
import org.mt4j.input.inputProcessors.componentProcessors.tapProcessor.TapProcessor;  
import org.mt4j.util.math.Vector3D;  

import processing.core.PApplet;  
import processing.core.PImage;  

public class MTPanel extends MTImageButton {

	boolean forbidOrizzontalDrag = false;          
	boolean forbidVerticalDrag = false;       
	
	public MTPanel(PImage texture, PApplet pApplet) {                  
		super(texture, pApplet);                
		setGesture();          
	}            
	
	private void setGesture() {                  
		this.setGestureAllowance(TapProcessor.class,false);                                    
		
		this.registerInputProcessor(new DragProcessor(this.getRenderer()));                  
		this.addGestureListener(DragProcessor.class, new DefaultDragAction());                  
		this.setGestureAllowance(DragProcessor.class,true);                                    
		
		this.registerInputProcessor(new ScaleProcessor(this.getRenderer()));                  
		this.addGestureListener(ScaleProcessor.class, new DefaultScaleAction());                  
		this.setGestureAllowance(ScaleProcessor.class,true);                  
		//          
	}            
	@Override          
	public void translate(Vector3D dirVect) {                    
		Vector3D direction = new Vector3D();                  
		direction.x = dirVect.x;                  
		direction.y = dirVect.y;                    
		if (forbidOrizzontalDrag)                          
			direction.x = 0;                  
		if (forbidVerticalDrag)                          
			direction.y = 0;                  
		//System.out.println("Sposto " + dirVect);                  
		super.translate(direction);          
	}            
	public boolean isForbidOrizzontalDrag() {                  
		return forbidOrizzontalDrag;          
	}            
	
	public void setForbidOrizzontalDrag(boolean forbidOrizzontalDrag) {                  
		this.forbidOrizzontalDrag = forbidOrizzontalDrag;          
	}            
	
	public boolean isForbidVerticalDrag() {                  
		return forbidVerticalDrag;          
	}            
	
	public void setForbidVerticalDrag(boolean forbidVerticalDrag) {                  
		this.forbidVerticalDrag = forbidVerticalDrag;          
	}    	
	
}
